#include "Lightorb.h"
#include "GamePlayState.h"
#include "Game.h"
#include "DestroyEntityMessage.h"
#include "../SGD Wrappers/SGD_GraphicsManager.h"
Lightorb::Lightorb()
{
	image = SGD::GraphicsManager::GetInstance()->LoadTexture("resources/images/orb.png");
}


Lightorb::~Lightorb()
{
	SGD::GraphicsManager::GetInstance()->UnloadTexture(image);
}

void Lightorb::Render()
{
	SGD::Rectangle camOffset{ { Game::GetInstance()->GetCameraPos().x - 100,
		Game::GetInstance()->GetCameraPos().y - 100 },
		SGD::Size{ (Game::GetInstance()->GetScreenWidth() + 500) / Game::GetInstance()->GetZoomLevel(),
		(Game::GetInstance()->GetScreenHeight() + 500) / Game::GetInstance()->GetZoomLevel() } };
	SGD::Rectangle posRect = { this->GetRect().ComputeCenter(), SGD::Size{ 1, 1 } };
	if (camOffset.IsIntersecting(posRect))
	{
		collisionFlag = 0;
		SGD::Point Worldposition;

		Worldposition.x = GetPosition().x - Game::GetInstance()->GetCameraPos().x;
		Worldposition.y = GetPosition().y - Game::GetInstance()->GetCameraPos().y;

		SGD::Point renderPos{ (position.x - Game::GetInstance()->GetCameraPos().x) * Game::GetInstance()->GetZoomLevel(),
			(position.y - Game::GetInstance()->GetCameraPos().y) * Game::GetInstance()->GetZoomLevel() };

		SGD::GraphicsManager::GetInstance()->DrawTexture(image, renderPos, rotation, { -1, -1 }, {},
		{ Game::GetInstance()->GetZoomLevel(), Game::GetInstance()->GetZoomLevel() });
	}
	else
		collisionFlag = -1;

}

void Lightorb::HandleCollision(const IEntity* other)
{
	
}